package dk.eaaa.mobil2012.indkoebsappnyere;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

public class Edit extends Fragment {
	
	TextView textname, textamount, textprice;
	Spinner unit;
	Button edit;
	MainActivity activity = (MainActivity) getActivity();
	
	@Override
	public void onDetach() {
		getActivity().getActionBar().show();
		super.onDetach();
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View v = inflater.inflate(R.layout.edit_layout, container, false);
		textname = (TextView) v.findViewById(R.id.editname);
		unit = (Spinner) v.findViewById(R.id.editunit);
		ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.units, android.R.layout.simple_list_item_1);
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		unit.setAdapter(adapter);
		textamount = (TextView) v.findViewById(R.id.editamount);
		textprice = (TextView) v.findViewById(R.id.editprice);
		edit = (Button) v.findViewById(R.id.edit);
		textname.setText(activity.getCurrentProduct().getName());
		textamount.setText(activity.getCurrentProduct().getAmount()+"");
		textprice.setText(activity.getCurrentProduct().getPrice()+"");
		return v;
	}
	
	

}
